package com.shixw_usr.MultiThreadedDownload;



import com.shixw_usr.MultiThreadedDownload.entity.DownloadInfo;
import com.shixw_usr.MultiThreadedDownload.manager.BaseDownloadMessageListener;
import com.shixw_usr.MultiThreadedDownload.manager.DownloadManager;


/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
    	DownloadManager dm = DownloadManager.getInstance().configDownloadParameter(1);
    	DownloadInfo downloadInfo = new DownloadInfo(null,"http://localhost:7001/doclinks/itunes6464setup.exe", "itunes6464setup.exe", "c:/", 3,"e704e2fc68c93a16bd66a18904d32fe80");
    	downloadInfo.setDownloadMessageListener(new BaseDownloadMessageListener());
    	dm.pushDownloadFile(downloadInfo,true);
    	try {
			dm.stopDownload();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
/*    	DownloadInfo downloadInfo2 = new DownloadInfo(null,"http://localhost:7001/doclinks/test.txt", "test.txt", "c:/", 3,"e704e2fc68c93a6bd66a18904d32fe80");
    	downloadInfo2.setDownloadMessageListener(new BaseDownloadMessageListener());
    	dm.pushDownloadFile(downloadInfo2,true);*/
    	/*    	try {
			DownloadFileSingleSplitter downloadFileSingleSplitter = new DownloadFileSingleSplitter("http://localhost:7001/doclinks/eclipse-jee-luna-SR1a-win32-x86_64.zip", "c:/", "eclipse-jee-luna-SR1a-win32-x86_64.zip", 0, 266281089, 1);
			downloadFileSingleSplitter.start();
    	} catch (IOException e1) {
			e1.printStackTrace();
		}*/
    /*	new Thread(){
			public void run() {
				try {
					InputStream in = new URL("http://localhost:7001/doclinks/eclipse-jee-luna-SR1a-win32-x86_64.zip").openStream();
//					 
					SaveItemFile saveItemFile = new SaveItemFile("c:/", "eclipse-jee-luna-SR1a-win32-x86_64.zip", 0);
					byte[] buff = new byte[1024 * 8];
					int length = -1;
					int i = 0;
					while((length=in.read(buff))>0){
						System.out.println(i+++"---"+length);
						saveItemFile.write(buff, 0, length);
					//	FileUtils.writeByteArrayToFile(new File("c:/Git-1.9.5-preview20150319.exe"),buff,true);
					}
					System.out.println("----------------");
					byte [] gif = IOUtils.toByteArray(in);
					FileUtils.writeByteArrayToFile(new File("c:/eclipse-jee-luna-SR1a-win32-x86_64.zip"),gif,true);
					saveItemFile.close();
					IOUtils.closeQuietly(in);
					System.out.println("�������");
				} catch (MalformedURLException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
			};
		}.start();*/
		System.out.println("--asdsadsa");
    }
}
